@extends('system.frame_layout')
<?php $parent_menu = "财务中心"; $menu_selected = "币种转换";?>

@section('content')
    <div id="content-panel">
        <div class="row">
            <div class="col-xs-12">
                <div class="portlet light bordered">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="icon-social-dribbble font-dark hide"></i>
                            <span class="caption-subject font-dark bold">币种转换 Coin Switch</span>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="form-group">
                            <form role="form" id="switchCoinAct" action="{{ route('sys.switch.coin-act') }}"
                                  method="post">
                                <div class="form-body">
                                    <input name="_token" value="{{csrf_token()}}" type="hidden"/>
                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            选择原币种 - Select Real Coin
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <select name="real_coin" class="form-control">
                                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_1}}">
                                                    奖金币（{{ $wallet->w1 }}）
                                                </option>
                                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_2}}">
                                                    报单币（{{ $wallet->w2 }}）
                                                </option>
                                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_3}}">
                                                    购物币（{{ $wallet->w3 }}）
                                                </option>
                                            </select>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            转换金额 - Switch Money
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input type="text" name="money" class="form-control"
                                                       placeholder="请输入转账金额">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label for="money" class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            选择目标币种 - Select Final Coin
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <select name="final_coin" class="form-control">
                                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_1}}">
                                                    奖金币（{{ $wallet->w1 }}）
                                                </option>
                                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_2}}">
                                                    报单币（{{ $wallet->w2 }}）
                                                </option>
                                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_3}}">
                                                    购物币（{{ $wallet->w3 }}）
                                                </option>
                                            </select>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            交易密码 - Safe Pass
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input type="password" name="safepass" class="form-control"
                                                       placeholder="请输入交易密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label for="passwd" class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <div class="col-xs-12">
                                            <button type="submit" class="btn blue-madison">
                                                <i class="iconfont icon-duihao"></i>&nbsp;立即转换
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('footer')
    <script>
        $("#switchCoinAct").validate({
            rules: {
                money: {
                    required: true
                },
                safepass: {
                    required: true
                }
            }, errorPlacement: function (error, element) {
                $(element).closest("form").find("label[for='" + element.attr("name") + "']").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location = "{{ route('sys.switch.log') }}";
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });
    </script>
@endsection